package top.lyunz.lucky.hr.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import top.lyunz.lucky.hr.bean.ConfigFileFirstKind1;
import top.lyunz.lucky.hr.bean.ConfigFileSecondKind1;
import top.lyunz.lucky.hr.bean.ConfigFileThirdKind1;
import top.lyunz.lucky.hr.bean.ConfigMajor1;
import top.lyunz.lucky.hr.bean.ConfigMajorKind1;
import top.lyunz.lucky.hr.bean.HumanfileDig;
import top.lyunz.lucky.hr.service.HumanfileDigService;

@Controller
@RequestMapping("move")
public class moveController {
	@Autowired
	private HumanfileDigService humanfileDigService;

	@RequestMapping("register_locate")
	public String move_1(Model model) {
		List<ConfigFileThirdKind1> all_sj = humanfileDigService.getAll_sj();
		List<ConfigFileFirstKind1> all_yj = humanfileDigService.getAll_yj();
		List<ConfigFileSecondKind1> all_ej = humanfileDigService.getAll_ej();
		model.addAttribute("sj", all_sj);
		model.addAttribute("ej", all_ej);
		model.addAttribute("yj", all_yj);
		return "/page/transfer/register_locate";
	}

	@RequestMapping("register_list")
	public String move_1_1(Model model, HumanfileDig humanfileDig) {
		List<HumanfileDig> all_D = humanfileDigService.getAll_D(humanfileDig);
		model.addAttribute("all_D", all_D);
		return "/page/transfer/register_list";
	}

	@RequestMapping("/register/{hfdId}")
	public String move_1_2(@PathVariable int hfdId, Model model) {
		HumanfileDig byId = humanfileDigService.getById(hfdId);
		model.addAttribute("byId", byId);

		List<ConfigFileThirdKind1> all_sj = humanfileDigService.getAll_sj();
		List<ConfigFileFirstKind1> all_yj = humanfileDigService.getAll_yj();
		List<ConfigMajorKind1> all_zf = humanfileDigService.getAll_zf();
		List<ConfigMajor1> all_zn = humanfileDigService.getAll_zn();
		List<ConfigFileSecondKind1> all_ej = humanfileDigService.getAll_ej();
		model.addAttribute("sj", all_sj);
		model.addAttribute("yj", all_yj);
		model.addAttribute("zf", all_zf);
		model.addAttribute("zn", all_zn);
		model.addAttribute("ej", all_ej);
		return "page/transfer/register";
	}
	
	@RequestMapping("/register_success")
	public String move_1_3(HumanfileDig humanfileDig) {
		humanfileDigService.update_sh(humanfileDig);
		return "page/transfer/register_success";
	}

	@RequestMapping("check_list")
	public String move_2(Model model) {
		List<HumanfileDig> all = humanfileDigService.getAll();
		model.addAttribute("all", all);
		return "page/transfer/check_list";
	}

	@RequestMapping("/check/{hfdId}")
	public String move_2_1(@PathVariable int hfdId, Model model) {
		// 查询单
		HumanfileDig byId = humanfileDigService.getById(hfdId);
		model.addAttribute("byId", byId);
		// 表单
		List<ConfigFileThirdKind1> all_sj = humanfileDigService.getAll_sj();
		List<ConfigFileFirstKind1> all_yj = humanfileDigService.getAll_yj();
		List<ConfigMajorKind1> all_zf = humanfileDigService.getAll_zf();
		List<ConfigMajor1> all_zn = humanfileDigService.getAll_zn();
		List<ConfigFileSecondKind1> all_ej = humanfileDigService.getAll_ej();
		model.addAttribute("sj", all_sj);
		model.addAttribute("yj", all_yj);
		model.addAttribute("zf", all_zf);
		model.addAttribute("zn", all_zn);
		model.addAttribute("ej", all_ej);
		return "/page/transfer/check";
	}

	@RequestMapping("/check_success")
	public String move_2_2(HumanfileDig humanfileDig) {
		humanfileDigService.update_sh(humanfileDig);
		return "/page/transfer/check_success";

	}

	@RequestMapping("locate")
	public String move_3(Model model) {
		List<ConfigFileThirdKind1> all_sj = humanfileDigService.getAll_sj();
		List<ConfigFileFirstKind1> all_yj = humanfileDigService.getAll_yj();
		List<ConfigMajorKind1> all_zf = humanfileDigService.getAll_zf();
		List<ConfigMajor1> all_zn = humanfileDigService.getAll_zn();
		List<ConfigFileSecondKind1> all_ej = humanfileDigService.getAll_ej();
		model.addAttribute("sj", all_sj);
		model.addAttribute("yj", all_yj);
		model.addAttribute("zf", all_zf);
		model.addAttribute("zn", all_zn);
		model.addAttribute("ej", all_ej);
		return "/page/transfer/locate";
	}

	@RequestMapping("list")
	public String move_3_1(Model model, HumanfileDig humanfileDig) {
		List<HumanfileDig> all_D = humanfileDigService.getAll_D(humanfileDig);
		model.addAttribute("all_D", all_D);
		return "/page/transfer/list";
	}

	@RequestMapping("/detail/{hfdId}")
	public String move_3_2(@PathVariable int hfdId, Model model) {
		HumanfileDig byId = humanfileDigService.getById(hfdId);
		model.addAttribute("byId", byId);
		return "/page/transfer/detail";
	}
}
